package cn.dancepeak.service.impl;

import cn.dancepeak.domain.Teacher;
import cn.dancepeak.mapper.TeacherMapper;
import cn.dancepeak.service.ITeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)//只读
public class TeacherServiceImpl implements ITeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public List<Teacher> getTeacher() {
        return teacherMapper.selectAll();
    }

    @Override
    @Transactional
    public void addTeacher(Teacher teacher) {

        teacherMapper.add(teacher);
    }

    @Override
    @Transactional
    public void updateTeacher(Teacher teacher) {
        teacherMapper.update(teacher);
    }

    @Override
    @Transactional
    public void deleteTeacherById(Long id) {

        teacherMapper.delete(id);
    }
}
